use anyhow::Result;
use hyper::Client;

use crate::cmd::Output;
use crate::cmd::common;
use crate::cmd::SectorInput;

pub async fn find_sector_ticket(sector: &SectorInput) -> Result<Option<Box<dyn Output>>> {
    let client = &Client::new();
    let (url, token) = &common::parse_miner()?;

    let miner = format!("f0{}", sector.miner);
    let miner = miner.as_str();

    let height = crate::full::sector_ticket_height(client, url, token, sector.number, miner).await?;
    let key = crate::full::chain_height_tipset(client, url, token, height).await?;
    let ticket = crate::full::sector_randomness(client, url, token, height, miner, key).await?;
    log::info!("ticket {:?}", ticket.clone());
    Ok(Option::None)
}